import http from './interface'

/**
 * 将业务所有接口统一起来便于维护
 * 如果项目很大可以将 url 独立成文件，接口分成不同的模块
 * 
 */

// 单独导出(测试接口) import {test} from '@/common/vmeitime-http/'
export const test = (data) => {
	/* http.config.baseUrl = "http://localhost:8080/api/"
	//设置请求前拦截器
	http.interceptor.request = (config) => {
		config.header = {
			"token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
		}
	} */
	//设置请求结束后拦截器
	http.interceptor.response = (response) => {
		console.log('个性化response....')
		//判断返回状态 执行相应操作
		return response;
	}
	return http.request({
		baseUrl: 'https://unidemo.dcloud.net.cn/',
		url: 'ajax/echo/text?name=uni-app',
		dataType: 'text',
		data,
	})
}

// 轮播图
export const banner = (data) => {
	return http.request({
		url: '/banner/36kr',
		method: 'GET',
		data,
		// handle:true
	})
}

// 登录
export const login = (data) => {
	return http.request({
		url: '/login/login',
		method: 'POST',
		data,
		// handle:true
	})
}

// 获取账号详细信息
export const getPersonalInformation = (data) => {
	return http.request({
		url: '/account/getPersonalInformation',
		method: 'POST',
		data,
		// handle:true
	})
}

// 获取全部分类（代参获取个别）
export const getHouseContact1 = (data) => {
	return http.request({
		url: '/uptownHouse/getHouseContact1',
		method: 'POST',
		data,
		// handle:true
	})
}

// 获取商品信息 typeId
export const getPayItemList2 = (data) => {
	return http.request({
		url: '/pay/getPayItemList2',
		method: 'POST',
		data,
		// handle:true
	})
}

// 查询订单
export const getItemBatchByCustomer = (data) => {
	return http.request({
		url: '/pay/getItemBatchByCustomer',
		method: 'POST',
		data,
		// handle:true
	})
}

// 查询订单明细？（订单表以及订单明细表）
export const setHouseContact = (data) => {
	return http.request({
		url: '/uptownHouse/setHouseContact',
		method: 'POST',
		data,
		// handle:true
	})
}

// 小区管理-查询
export const getUptown = (data) => {
	return http.request({
		url: '/uptown/getUptown',
		method: 'POST',
		data,
		// handle:true
	})
}

// 添加商品
export const getPayOrderPage = (data) => {
	return http.request({
		url: '/pay/getPayOrderPage',
		method: 'POST',
		data,
		// handle:true
	})
}

// 账号注册 0厂家/1经销商/2农户/3批发商
export const addCustomer = (data) => {
	return http.request({
		url: '/account/addCustomer',
		method: 'POST',
		data,
		// handle:true
	})
}

// 设置账号详细信息
export const updateCustomer = (data) => {
	return http.request({
		url: '/account/updateCustomer',
		method: 'POST',
		data,
		// handle:true
	})
}

// 获取厂商信息，商城
export const getHouseContact = (data) => {
	return http.request({
		url: '/uptownHouse/getHouseContact',
		method: 'POST',
		data,
		// handle:true
	})
}

// 楼栋管理-查询
export const getUptownBuilding = (data) => {
	return http.request({
		url: '/uptown/getUptownBuilding',
		method: 'POST',
		data,
		// handle:true
	})
}

// 添加商品生成订单
export const orderPayOrder = (data) => {
	console.log(data)
	return http.request({
		baseUrl: 'http://xnt.longshunha.com:88/xnt',
		//baseUrl: 'http://192.168.0.3:8080/xnt',
		url: '/order/payOrder',
		method: 'POST',
		data,
		// handle:true
	})
}

// 更新商品信息 下架
export const getHouses = (data) => {
	return http.request({
		url: '/uptownHouse/getHouses',
		method: 'POST',
		data,
		// handle:true
	})
}

// 添加商品库存 减少商品库存
export const getUptownUnit = (data) => {
	return http.request({
		url: '/uptown/getUptownUnit',
		method: 'POST',
		data,
		// handle:true
	})
}

// 添加商品库存 减少商品库存
export const getPrice = (data) => {
	return http.request({
		url: '/pay/getPrice',
		method: 'POST',
		data,
		// handle:true
	})
}

// 添加商品库存 减少商品库存
export const pay = (data) => {
	return http.request({
		url: '/pay/pay',
		method: 'POST',
		data,
		// handle:true
	})
}

// 默认全部导出  import api from '@/common/vmeitime-http/'
export default {
	test,
	banner,
	getUptown,
	login,
	getPayItemList2,
	getItemBatchByCustomer,
	setHouseContact,
	getPersonalInformation,
	getPayOrderPage,
	addCustomer,
	updateCustomer,
	getHouseContact,
	orderPayOrder,
	getUptownBuilding,
	getHouses,
	getUptownUnit,
	getPrice,
	pay,
}
